<?php
/**
 * Created by PhpStorm.
 * User: j28981
 * Date: 2015/8/24
 * Time: 9:45
 * 后台控制器基类
 */
class  Action{
    public function __construct(){
        DB::dbInstall();
    }
    /**
     * @param $msg：提示信息
     * @param $url：将要跳转到的页面，也就是重新请求一个方法
     * @param int $type:0表示错误提示，1为正确提示
     */
    protected function showMessage($msg,$url='',$type=0){
        if($url==''){
            $url = $_SERVER['HTTP_REFERER'];
        }
        $msgstr = "<div>$msg</div>";
        if($type==1){
            $msgstr.= "<style>div{padding:10px;border:1px solid #2c7;border-radius:10px;color:green;background-color: #2c7;color:#fff;position:absolute;left:45%;top:45%;}</style><script>setTimeout(function(){window.location.href='$url'},2000);</script>";
        }elseif($type==0){
            $msgstr.= "<style>div{padding:10px;border:1px solid  #f60;border-radius:5px;color:green;background-color:  #f60;color:#fff;position:absolute;left:45%;top:45%;}</style><script>setTimeout(function(){window.location.href='$url'},3000);</script>";
        }else{
            exit('参数有误');
        }
        echo $msgstr;
        exit;
    }
    //定位到不同的控制器中的某个方法
    protected function redirect($url){
       @header("Location:$url");
    }
    protected function date_format($time){
        return date('Y-m-d H:m:i',$time);
    }

}